package com.glela.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.BaseRestrictions;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.model.response.ResponseResultModel;
import com.glela.platform.service.BaseRestrictionsService;
import com.glela.talent.model.request.BaseRestrictionsRequest;

@Controller
@RequestMapping("/baseRestrictions")
public class BaseRestrictionsController {

	private static Logger logger = LoggerFactory.getLogger(UserDailyLogController.class);

	@Autowired
	private BaseRestrictionsService baseRestrictionsService;

	/**
	 * 后台参数查询接口（1、满XX开店；2、满XXX提现；3、满XX立减折扣）
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/selectAllBaseRestrictionsByType", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> selectAllBaseRestrictionsByType(@RequestBody BaseRestrictionsRequest model) {
		try {
			//根据类型查询限制信息
			BaseRestrictions listBaseRestrictions = baseRestrictionsService
					.selectAllBaseRestrictionsByType(model.getType());
			return new ResponseEntity<>(new ResponseResultModel<BaseRestrictions>(listBaseRestrictions), HttpStatus.OK);
		} catch (Exception e) {
			logger.error("异常啦", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
}
